import service from '@/utils/axios';
import { IResponseType, PageVO } from '@/api/common';
import {
    CommentAddRO,
    CommentEditRO,
    CommentPageRO, CommentPageVO,
    CommentVO
} from '@/api/content/comment/comment';

export const getCommentInfo = (id: string) => {
    return service<IResponseType<CommentVO>>({
        url: '/content/comment/get/' + id,
        method: 'post'
    });
};

export const getCommentAll = async () => {
    const pageVo = await service<IResponseType<PageVO<CommentVO>>>({
        url: '/content/comment/page',
        method: 'post',
        data: {
            current: 1,
            size: 1000
        }
    });
    return pageVo.data;
};

export const getCommentPage = (pageRO: CommentPageRO) => {
    return service<IResponseType<PageVO<CommentPageVO>>>({
        url: '/content/comment/page',
        method: 'post',
        data: pageRO
    });
};

export const getCommentSonPage = (pageRO: CommentPageRO) => {
    return service<IResponseType<PageVO<CommentPageVO>>>({
        url: '/content/comment/sonPage',
        method: 'post',
        data: pageRO
    });
};

export const addComment = (data: CommentAddRO) => {
    return service<IResponseType<void>>({
        url: '/content/comment/add',
        method: 'post',
        data
    });
};

export const editComment = (data: CommentEditRO) => {
    return service<IResponseType<void>>({
        url: '/content/comment/edit',
        method: 'post',
        data
    });
};

export const remove = (ids: string) => {
    return service<IResponseType<void>>({
        url: '/content/comment/remove/' + ids,
        method: 'post'
    });
};

export const support = (id: string, isSupport: boolean) => {
    return service<IResponseType<void>>({
        url: `/content/comment/support/${id}/${isSupport}`,
        method: 'post'
    });
};
